home *** CD-ROM | disk | FTP | other *** search
/ Deutsche Edition 1 / Deutsche Edition 1.iso / amok / amok_lha / amok15.lha / Seafarers_Manual / Source / Pendulum.mod < prev    next >
Text File  |  1993-08-15  |  1KB  |  51 lines

  1. MODULE Pendulum;   (* Calculate velocity & acceleration of
  2.               swinging pendulum *)
  3.                       
  4.    (* From the book "Modula-2  A Seafarer's Manual and Shipyard Guide" *)
  5.    (* Page 37   adapted "Amiga M2Modula-2"   21 Feb 1988 *)
  6.    
  7. FROM InOut IMPORT WriteLn,
  8.           WriteString;
  9. FROM RealInOut IMPORT WriteReal,
  10.               ReadReal;
  11. FROM MathLib0 IMPORT sin,
  12.              cos;
  13.                      
  14. CONST
  15.   fieldwidth = 10;    (* width of output field *)
  16.   decimaldigit = 8;    (* number of output decimal digits *)
  17. VAR
  18.   r,            (* input-pendulum length *)
  19.   w,            (*       angular velocity *)
  20.   t,            (*       time *)
  21.   velocity,        (* velocity result *)
  22.   acceleration : REAL;    (* acceleration result *)
  23.   
  24. BEGIN
  25.   WriteLn;
  26.   WriteString ("Enter pedulum length: ");
  27.   ReadReal (r);        (* get length from keyboard *)
  28.   
  29.   WriteLn;
  30.   WriteString ("Enter angular velocity: ");
  31.   ReadReal (w);        (* get velocity from keyboard *)
  32.   
  33.   WriteLn;
  34.   WriteString ("Enter time: ");
  35.   ReadReal (t);        (* get time from keyboard *)
  36.   
  37.   velocity := (r * w) * (cos(w * t));
  38.   acceleration := (r * (w * w)) * (sin(w * t));
  39.   
  40.   WriteLn;
  41.   WriteString ("Velocity = ");
  42.   WriteReal (velocity,fieldwidth,decimaldigit);
  43.   
  44.   WriteLn;
  45.   WriteString ("Acceleration = ");
  46.   WriteReal (acceleration,fieldwidth, decimaldigit);
  47.   
  48.   WriteLn;
  49.   
  50. END Pendulum.
  51.